<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::get('/', function () {
    return view('welcome');
});

Route::get('/userlist', function () {
    $pdo = new PDO('mysql:host=127.0.0.1;dbname=samsung;charset=utf8','root','');
    $sql = 'select * from `user`';
    $res = $pdo->query($sql);
    $res = $res->fetchAll();
    return view('userlist')->with('data',$res);
});
Route::get('/userlistp', function () {
    $pdo = new PDO('mysql:host=127.0.0.1;dbname=samsung;charset=utf8','root','');
    $sql = 'select id,nickname,tel,birthday,sex from `user`';
    $res = $pdo->query($sql);
    $res = $res->fetchAll(PDO::FETCH_ASSOC);
    return $res;
});
Route::post('/userinfo',function () {
    $id = $_POST['id'];
    $nickName = $_POST['nickName'];
    $tel = $_POST['tel'];
    $birthday = $_POST['birthday'];
    $sex = $_POST['sex'];
    $pdo = new PDO('mysql:host=127.0.0.1;dbname=samsung;charset=utf8','root','');
    $sql = 'update user set nickname="'.$nickName.'",tel='."$tel".',birthday="'.$birthday.'",sex='."$sex".' where id='.$id;
//    var_dump($sql);
    $res = $pdo->exec($sql);
    var_dump($res);
});

Route::get('/aa','UserController@UserList');
Route::get('/bb','UserController@UserList');